﻿@model Contoso.Models.Instructor

@{
    ViewBag.Title = "Edit";
}

<h2>Edit</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Instructor</legend>

        @Html.HiddenFor(model => model.InstructorID)

        <div class="editor-label">
            @Html.LabelFor(model => model.LastName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.LastName)
            @Html.ValidationMessageFor(model => model.LastName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.FirstMidName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.FirstMidName)
            @Html.ValidationMessageFor(model => model.FirstMidName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.HireDate)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.HireDate)
            @Html.ValidationMessageFor(model => model.HireDate)
        </div>


         <div class="editor-label">
            @Html.LabelFor(model => model.OfficeAssignment.Location)
        </div>
        <div class="editor-field">
      
            @Html.EditorFor(model => model.OfficeAssignment.Location)
       
            @Html.ValidationMessageFor(model => model.OfficeAssignment.Location)
        </div>

        <div class="editor-field"> 
    <table> 
        <tr> 
            @{ 
                int cnt = 0;
                List<Contoso.ViewModels.AssignedCourseData> courses = ViewBag.Courses; 
 
                foreach (var course in courses) { 
                    if (cnt++ % 3 == 0) { 
                        @:  </tr> <tr>  
                    } 
                    @: <td>  
                        <input type="checkbox"  
                               name="selectedCourses"  
                               value="@course.CourseID"  
                               @(Html.Raw(course.Assigned ? "checked=\"checked\"" : "")) />  
                        @course.CourseID @:  @course.Title 
                    @:</td> 
                } 
                @: </tr> 
            } 
    </table> 
</div>
        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
